package com.itcast.gameforum.mapper;

import com.itcast.gameforum.entity.Mainposts;
import com.itcast.gameforum.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 647zyzlq
 * @since 2020-10-21
 */

public interface UserMapper extends BaseMapper<User> {


    @Update("update user set password=#{newPassword} where username=#{username}")
    public void alterPassword(String username,String newPassword);

    @Update("update user set avatar=#{newavatar} where username=#{username}")
    public void uploadAvatar(String username,String newavatar);

    @Insert("insert into user(username,password,status,avatar,email,name) values(#{username},#{password},#{status},#{avatar},#{email},#{name})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int saveUser(User user);
}
